package com.jingyu.sport.services.impl;

import com.jingyu.sport.FirstAppRepository;
import com.jingyu.sport.domian.FirstApp;
import com.jingyu.sport.services.FirstAppService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class FirstAppServiceImpl implements FirstAppService {

    @Autowired
    private FirstAppRepository firstAppRepository;


    @Override
    public void add(FirstApp app) {
        firstAppRepository.save(app);
    }

    @Override
    public void remove(int id) {
        firstAppRepository.deleteById(id);
    }

    @Override
    public void update(FirstApp app) {
        firstAppRepository.save(app);
    }

    @Override
    public List<FirstApp> query() {
        return firstAppRepository.findAll();
    }

    @Override
    public FirstApp get(int id) {
        Optional<FirstApp> optional =firstAppRepository.findById(id);
        return optional.isPresent()?optional.get(): null;
    }
}
